<ui:composition template="/WEB-INF/templates/main-template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="sidebar">
		<ui:include src="/WEB-INF/templates/public-sidebar.xhtml" />
	</ui:define>
	<ui:define name="content">

		<h:form id="employeeRegisterForm">
			<p:growl id="messages" showDetail="true" />

			<p:panel header="Register Employee">
				<h:panelGrid style="width: 100%;">

					<h:panelGrid columns="2"  style="float: right;">
						<h:outputText value="Get registration details from e-form" />
						<p:menuButton id="regChoice" value="#{employeeRegisterBean.REGISTRATION_THROUGH_EFORM}">
							<p:menuitem value="Yes" actionListener="#{employeeRegisterBean.registrationThroughEformToggleListener}" update="@form" />
							<p:menuitem value="No" actionListener="#{employeeRegisterBean.registrationThroughEformToggleListener}" update="@form" /> 							
						</p:menuButton>
					</h:panelGrid>

					<h:panelGrid style="width: 100%"
						rendered="#{employeeRegisterBean.REGISTRATION_THROUGH_EFORM eq 'Yes'}">

						<h:outputLabel
							value="New Joinees List (Select a new joinee to register as an employee)"
							styleClass="outputTextSubTitle" />
						<p:dataTable var="newJoinee"
							value="#{employeeRegisterBean.newJoineesList}">
							<p:column>
								<f:facet name="header">
									<h:outputText value="Full Name" />
								</f:facet>
								<h:outputText
									value="#{newJoinee.firstName} #{newJoinee.lastName}" />
							</p:column>
							<p:column>
								<f:facet name="header">
									<h:outputText value="Date of birth" />
								</f:facet>
								<h:outputText value="#{newJoinee.dateofbirth}">
									<f:convertDateTime pattern="dd-MMM-yyyy"></f:convertDateTime>
								</h:outputText>

							</p:column>
							<p:column>
								<f:facet name="header">
									<h:outputText value="Telephone" />
								</f:facet>
								<h:outputText value="#{newJoinee.telephone}" />

							</p:column>
							<p:column>
								<f:facet name="header">
									<h:outputText value="Email" />
								</f:facet>
								<h:outputText value="#{newJoinee.email}" />

							</p:column>
							<p:column headerText="Date of joining">
								<h:outputText value="#{newJoinee.dateOfJoining}">
									<f:convertDateTime pattern="dd-MMM-yyyy"></f:convertDateTime>
								</h:outputText>
							</p:column>

							<p:column style="text-align: center;">
								<p:commandButton value="Select"
									action="#{employeeRegisterBean.copyEmployeeFromNewJoinee}"
									update="@form">
									<f:setPropertyActionListener value="#{newJoinee}"
										target="#{employeeRegisterBean.selectedNewJoinee}" />
								</p:commandButton>
							</p:column>

						</p:dataTable>
					</h:panelGrid>

					<h:panelGrid columns="8" style="width: 100%;" columnClasses="">

						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="Employee Code" />
						<h:outputLabel value=" : " />
						<p:inputText value="#{employeeRegisterBean.employee.employeeCode}"
							readonly="true" />

						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="Date of Joining " />
						<h:outputLabel value=" : " />
						<h:panelGroup>
						 <p:calendar value="#{employeeRegisterBean.employee.dateOfJoining}" readOnlyInputText="true" id="doj" navigator="true" yearRange="c:c+1" pattern="dd-MMM-yyyy" />
						 <p:watermark value="DD-MMM-YYYY" for="doj"></p:watermark>
                        </h:panelGroup> 
						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="First Name " />
						<h:outputLabel value=" : " />
						<p:inputText value="#{employeeRegisterBean.employee.firstName}" />
						<p:inputText value="#{employeeRegisterBean.employee.firstName}"
							binding="#{employeeRegisterBean.firstNameInputText}"
							rendered="false"></p:inputText>

						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="Last Name " />
						<h:outputLabel value=" : " />
						<p:inputText value="#{employeeRegisterBean.employee.lastName}" />

						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="Contact Number " />
						<h:outputLabel value=" : " />
						<p:inputMask value="#{employeeRegisterBean.employee.telephone}"
							mask="(999) 999-9999" />

						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="Email " />
						<h:outputLabel value=" : " />
						<p:inputText value="#{employeeRegisterBean.employee.email}" />

						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="Date of Birth " />
						<h:outputLabel value=" : " />
						<p:calendar navigator="true" display="inline" readOnlyInputText="true" yearRange="c-80:c+2" value="#{employeeRegisterBean.employee.dateOfBirth}" pattern="dd-MMM-yyyy"/>

						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="Location " />
						<h:outputLabel value=" : " />
						<p:inputText value="#{employeeRegisterBean.employee.location}" />

						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="Primary Skill " />
						<h:outputLabel value=" : " />
						<p:inputTextarea
							value="#{employeeRegisterBean.employee.primarySkill}" />

						<h:inputHidden />
						<h:outputLabel value="Secondary Skill " />
						<h:outputLabel value=" : " />
						<p:inputTextarea
							value="#{employeeRegisterBean.employee.secondarySkill}" />

						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="Module Name " />
						<h:outputLabel value=" : " />
						<h:panelGrid>
						<h:panelGroup>
						<p:selectOneMenu   
							value="#{employeeRegisterBean.employee.moduleName}"
							style="width: 159px;">
							<p:ajax event="change" listener="#{employeeRegisterBean.otherModuleListner}" process="@this" update="otherModule"></p:ajax>
							<f:selectItem itemLabel="Select" itemValue="" />
							<f:selectItems value="#{employeeRegisterBean.saperpModules}" />
							
						</p:selectOneMenu><br/>
						 
						 
						<h:panelGroup id="otherModule">
						 <p:inputText value="#{employeeRegisterBean.otherModule}" rendered="#{employeeRegisterBean.RENDER_OTHER_MODULE}" ></p:inputText>
						 <p:watermark value="Enter new module here" for="otherModule"></p:watermark>
						 </h:panelGroup>
                       </h:panelGroup>  
                       </h:panelGrid>
						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="Designation" />
						<h:outputLabel value=" : " />
						<h:panelGrid>
						<h:panelGroup>
						<p:selectOneMenu
							value="#{employeeRegisterBean.employee.designation}"
							style="width: 159px;" >
							<p:ajax event="change" listener="#{employeeRegisterBean.otherDesignationListner}" process="@this" update="otherDesignation"></p:ajax>
							<f:selectItem itemLabel="Select" itemValue="" />
							<f:selectItems value="#{employeeRegisterBean.designationsMap}" />
						</p:selectOneMenu><br/>
                         
						<h:panelGroup id="otherDesignation">
						 <p:inputText value="#{employeeRegisterBean.otherDesignation}" rendered="#{employeeRegisterBean.RENDER_OTHER_DESIGNATION}" ></p:inputText>
						 <p:watermark value="Enter new designation here" for="otherDesignation"></p:watermark>
						 </h:panelGroup>
						 </h:panelGroup>
						 </h:panelGrid>
						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="Role " />
						<h:outputLabel value=" : " />
						<p:selectOneMenu value="#{employeeRegisterBean.role.roleId}"
							style="width: 159px;" >
							<f:selectItem itemLabel="Select" itemValue="" />
							<f:selectItems value="#{employeeRegisterBean.rolesMap}"></f:selectItems>
						</p:selectOneMenu>

						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="Project Manager " />
						<h:outputLabel value=" : " />
						<h:panelGrid>
							<p:selectOneMenu id="projectManager"
								value="#{employeeRegisterBean.projectManager.employeeId}"
								style="width: 159px;" >
								<f:selectItem itemLabel="Select" itemValue="" />
								<f:selectItems
									value="#{employeeRegisterBean.projectManagersMap}"></f:selectItems>
							</p:selectOneMenu>

						</h:panelGrid>

						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="Competency Lead " />
						<h:outputLabel value=" : " />
						<h:panelGrid>
							<p:selectOneMenu id="compentencyLead"
								value="#{employeeRegisterBean.competency.employeeId}"
								style="width: 159px; margin-left: -1px;" >
								<f:selectItem itemLabel="Select" itemValue="" />
								<f:selectItems
									value="#{employeeRegisterBean.competencyLeadsMap}"></f:selectItems>
							</p:selectOneMenu>
						</h:panelGrid>

						<h:outputLabel value="*" style="color : red;" />
						<h:outputLabel value="Center Head  " />
						<h:outputLabel value=" : " />
						<h:panelGrid>
							<p:selectOneMenu id="centerHead"
								value="#{employeeRegisterBean.centerHead.employeeId}"
								style="width: 159px;" >
								<f:selectItem itemLabel="Select" itemValue="" />
								<f:selectItems value="#{employeeRegisterBean.centerHeadMap}"></f:selectItems>
							</p:selectOneMenu>

						</h:panelGrid>




						<!--
							
							<h:inputHidden  />
							<h:outputLabel value="Project Start Date " />
							<h:outputLabel value=" : " />
							<h:panelGrid>
							<p:calendar id="projectStartDate" value="#{employeeRegisterBean.employeeAndReporting.startDate}" />
							 <p:tooltip for="projectStartDate" hideEvent="mousedown mouseout">
						           <h:outputText value="Project Start Date is optional for Vice Precident" styleClass="tooltipOutputLabel"/>
					         </p:tooltip>
		                    </h:panelGrid>
		                    
							<h:inputHidden  />
							<h:outputLabel value="Project End Date " />
							<h:outputLabel value=" : " />
							<h:panelGrid>
							 <p:calendar id="projectEndDate" value="#{employeeRegisterBean.employeeAndReporting.endDate}" />
		                       <p:tooltip for="projectEndDate" hideEvent="mousedown mouseout">
						           <h:outputText value="Project End Date is optional for Vice Precident" styleClass="tooltipOutputLabel"/>
					          </p:tooltip>
		                     </h:panelGrid>
							  
							<h:outputLabel value="Last Rolloff Date " />
							<h:outputLabel value=" : " />
							<p:calendar
								value="#{employeeRegisterBean.employeeAndReporting.lastRolloffdate}" />
		
							<h:outputLabel value="Date of Relieving  " />
							<h:outputLabel value=" : " />
							<p:calendar
								value="#{employeeRegisterBean.employeeAndReporting.dateOfRelieving}" />
		
							<h:outputLabel value="Relieved " />
							<h:outputLabel value=" : " />
							<p:inputText value="#{employeeRegisterBean.employee.relieved}" />
		
		
							<h:inputHidden />
							<h:inputHidden />
		                     -->

						<h:inputHidden />
						<h:inputHidden />

					</h:panelGrid>
					<h:panelGrid
						style="padding-top: 5px; width: 100%; border-top: 1px solid #d9d9d9"
						columnClasses="gridCellMiddleRightAligned">
						<h:panelGroup>
							<p:commandButton value="Submit" update="@form"
								action="#{employeeRegisterBean.saveEmployee}" ajax="false" />
							<p:commandButton value="Reset" action="registeremployee" />
						</h:panelGroup>
					</h:panelGrid>
				</h:panelGrid>


			</p:panel>

		</h:form>

	</ui:define>
</ui:composition>

